<?php
namespace App\Observers;
use App\Handlers\SlugTranslateHandler;
use App\Jobs\TranslateSlug;
use App\Models\Post;

/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019/1/9 0009
 * Time: 15:51
 */
class PostObserver {
    public function saving(Post $post) {
        $post->excerpt = str_limit(html2txt($post->content),200);
        if (!$post->slug) {
            dispatch(new TranslateSlug($post));
        }
    }
}